package com.gs.djys.land;

import android.app.Activity;

import com.alibaba.fastjson.JSON;
import com.gs.djys.Base.MyAppliCation;
import com.gs.djys.Base.Urls;
import com.gs.djys.callback.StringDialogCallback;
import com.gs.djys.mvp.BasePresenterImpl;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheMode;
import com.lzy.okgo.callback.FileCallback;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

import java.io.File;


/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class LandPresenter extends BasePresenterImpl<LandContract.View> implements LandContract.Presenter{
    @Override
    public void Land(String username, String password, Activity Activity) {
        OkGo.<String>get(Urls.SERVER+"/road/lictran/licApp/login")
                .params("username",username)
                .params("password",password)
                .execute(new StringDialogCallback(Activity) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        LandBean landBean = JSON.parseObject(response.body(),LandBean.class);
                        if (mView == null)
                            return;
                        if (landBean.getCode().equals("0000")){
                            mView.getLand(landBean);
                        }else {
                            mView.onRequestError(landBean.getMessage());
                        }
                    }
                });
    }
    @Override
    public void getTJ() {
        OkGo.<String>get(Urls.SERVER + "/road/lictran/licApp/request/tj")
                .params("user_code", MyAppliCation.spUtils.getString("userCode"))
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        mView.getTJs(response.body().toString());
                    }
                });
    }
}
